<template>
	<div class="root">
		<div class="basicInfo">
			<div style="flex: 1.5;">
				<span>
				  赛事名称：
				  <b>{{ MatchSign.com_name }}</b>
				</span>
				<span>
				  裁判长：
				  <b>{{ MatchSign.referee_name }}</b>
				</span>
			</div>
			<div>
				<el-button type="warning" @click="back" size="small" class="copy-btn-MoreDisplay">返回</el-button>
			</div>
		</div>
		<el-table
			:data="tableData"
			stripe
			style="width: 100%">
			<el-table-column
				prop="id"
				label="ID"
				width="80">
			</el-table-column>
			<el-table-column
				prop="user_id"
				width="120"
				label="用户ID">
			</el-table-column>
			<el-table-column
				prop="content"
				label="日志内容"
			>
			</el-table-column>
			<el-table-column
				prop="create_time"
				label="时间">
			</el-table-column>
		</el-table>
		<div class="pagenation">
			<el-pagination
				background
				@current-change="judgePage"
				@prev-click="prevPage"
				@next-click="nextPage"
				layout="prev, pager, next"
				:total="total">
			</el-pagination>
		</div>
	</div>
</template>

<script>
export default {
		data() {
			return {
				tableData: [],
				page:1,
                total:0,
				limit:10,
				MatchSign:[]
			}
		},
		created() {
			this.getLog();
			this.getCompeInfo()
		},
		methods:{
			getLog(type){
				let page = this.page
				if(type == 1){
					// 上一页
					page--
				}else if(type==2){
					// 下一页
					page++
				}else{
					page
				}
				// console.log(page)
				this.$axios.post('role/get_com_log',this.$route.query.MatchId?{page,limit:this.limit,com_id:this.$route.query.MatchId}:{page,limit:this.limit},{headers:{token:sessionStorage.getItem('token')}})
				.then(res=>{
					if(res.data.code==2000){
						this.tableData = res.data.data.list
						this.total = res.data.data.count
					}else{
						this.$message.error(res.data.msg)
					}
				})
			},
			// 下一页
			nextPage(){
				// console.log('下一页')
				this.getLog(2)
			},
			// 上一页
			prevPage(){
				// console.log('上一页')
				this.getLog(1)
			},
			judgePage(e){
				this.page=e
				this.getLog()
				// console.log('直接')
			},
			getCompeInfo() {
			  this.$axios
			    .get('/competition/getCompeInfo', {
			      params: {
			        com_id: this.$route.query.MatchId
			      },
			      headers: {
			        token: window.sessionStorage.getItem('token')
			      }
			    })
			    .then(res => {
			      if (res.data.code) {
			        this.MatchSign = res.data.data;
			      }
			    })
			    .catch(res => {
			      console.log(res);
			    });
			},
			back(){
				this.$router.back()
			},
		}
	}
</script>

<style scoped lang="less">
	.root{
		padding: 50px;
		.basicInfo {
		background: linear-gradient(90deg, rgba(66, 185, 131, 0.2), rgba(66, 185, 131, 0.4));
		border-radius: 2px;
		line-height: 30px;
		height: 30px;
		padding: 15px;
		margin: 10px 0;
		overflow: hidden;
		display: flex;
		justify-content: space-around;
		align-items: center;
		span {
			margin-right: 20px;
		}
		.btnGroup {
			margin-right: 20px;
		}
		.date {
			width: 25%;
			padding: 10px 15px;
		}
	}
	}	
	.pagenation{
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 60px;
	}
</style>
